package java.JavaBean;

import org.apache.ibatis.javassist.bytecode.FieldInfo;
import org.apache.ibatis.javassist.bytecode.MethodInfo;

import java.lang.reflect.Modifier;

public class GetClassInfo {
    public static void main(String[] args) {
        Class clz = JavaBean.Person.class;
        String fullName = clz.getName();
        String simpleName = clz.getSimpleName();
        System.out.println("以下是"+fullName+"的信息");
        System.out.println("-----------------------");
        Package pkg = clz.getPackage();
        System.out.println(simpleName+"定义在:"+pkg.getName()+"包中");
        System.out.println("-----------------------");
        Class superClass  = clz.getSuperclass();
        System.out.println(simpleName+"类的超类是"+superClass.getName());
        System.out.println("-----------------------");
        Class[] interfaces = clz.getInterfaces();
        System.out.println(simpleName+"类实现的接口");
        for(Class inter:interfaces){
            System.out.println("\t"+inter.getName()+"接口");
        }
        System.out.println("-----------------------");
        int modifier = clz.getModifiers();
        System.out.println(simpleName+"类的修饰符:");
        if ((modifier & Modifier.PUBLIC) == Modifier.PUBLIC)
            System.out.println("\t访问修饰符是：public");
        else
            System.out.println("\t访问修饰符是：default(pacakge)");
        if ((modifier & Modifier.FINAL) == Modifier.FINAL)
            System.out.println("\t这个类是final的");
        if ((modifier & Modifier.ABSTRACT) == Modifier.ABSTRACT)
            System.out.println("\t这个类是抽象类");
        if ((modifier & Modifier.INTERFACE) == Modifier.INTERFACE)
            System.out.println("\t这个类是接口");
        System.out.println("-----------------------");
    }
}
